<?php
/**
 * @package		简易CMS
 * @subpackage	系统后台入口
 * @version		$Id: admin.php 25 2012-08-29 17:55:19Z htmambo@gmail.com $
 * @author		Hoping
 * @copyright	Copyright (C) 2010 Hoping Software Studio.
 */


define('IN_ADMINCP', TRUE);
define('NOROBOT', TRUE);
define('ADMINSCRIPT', basename(__FILE__));
define('CURSCRIPT', 'admin');


require './source/class/class_core.php';
require './source/class/class_admincp.php';
require './source/function/function_misc.php';
require './source/function/function_admincp.php';
require './source/function/function_cache.php';

$mainframe = & cmsCore::instance();
$mainframe->init();
/*
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-store, no-cache, must-revalidate" );
header( "Cache-Control: post-check=0, pre-check=0", false );
header( "Pragma: no-cache" );
*/
$admincp = new cmsAdminCP();
$admincp->core  = & $mainframe;
$admincp->init();


$admincp_actions_founder = array('templates', 'db', 'founder');
$admincp_actions_normal = array(
	'index', 'setting', 'members', 'profilefields', 'admingroup', 'usergroups',
	'moderate', 'attach',
	'styles', 'announce',
	'counter', 'misc', 'adv', 'logs', 'tools', 'portalperm',
	'checktools', 'search', 'upgrade', 'article', 'block', 'blockstyle', 'portalcategory', 'credits',
	'comment', 'click', 'specialuser', 'report',
	'diytemplate', 'verify', 'nav', 'spider', 'customfields', 'plugins');

$action = getgpc('action');
$operation = getgpc('operation');
$do = getgpc('do');
$frames = getgpc('frames');
lang('admincp');
$lang = & $_G['lang']['admincp'];
$page = max(1, intval(getgpc('page')));
$isfounder = $admincp->isfounder;

if(empty($action) || $frames != null) {
	$admincp->show_admincp_main();
} elseif($action == 'logout') {
	$admincp->do_admin_logout();
	dheader("Location: ./index.php");
} elseif(in_array($action, $admincp_actions_normal) || ($admincp->isfounder && in_array($action, $admincp_actions_founder))) {
	if($admincp->allow($action, $operation, $do) || $action == 'index') {
		require $admincp->admincpfile($action);
	} else {
		cpheader();
		cpmsg('Sorry, you have not access', '', 'error');
	}
} else {
	cpheader();
	cpmsg('Sorry, you have not access', '', 'error');
}
